home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS11.ADF / Progs / PS.CPri.DOC < prev    next >
Text File  |  1986-08-05  |  3KB  |  84 lines

  1. /*
  2. Here's a belated contribution to the discussion on process priorities.
  3. cpri uses the Exec SetTaskPri function to fiddle around with the process
  4. priorities of running CLI processes.
  5.  
  6. I've also thrown in a "ps" command, as a replacement for "status". I've
  7. no idea why status displays all those question marks - ps gives you the
  8. command name instead.
  9.  
  10. This posting contains the following items:
  11.         ps+cpri.doc     a readme file
  12.         ps.c            source for the ps command
  13.         cpri.c          source for the cpri command
  14.         ps.Z.b          the executable, run through compress and btoa
  15.         cpri.Z.b        the executable, run through compress and btoa
  16.  
  17. To regenerate the executables, run them through atob and then uncompress (or
  18. compress -d). atob, btoa and compress are part of the mod.sources
  19. distribution.
  20.  
  21. ------------------------------ cut here ----------------------------------
  22. echo "creating source files:"
  23. echo "\tps+cpri.doc"
  24. cat <<"FUNKYSTUFF" >ps+cpri.doc
  25.                 Documentation for the ps and cpri commands
  26.                 ------------------------------------------
  27. ps and cpri are commands that allow you to investigate and change the
  28. priorities of running AmigaDOS processes. In addition, ps can be viewed
  29. as a replacement for the "status" command.
  30.  
  31. syntax
  32. ------
  33.         cpri priority CLI-process-number
  34.         ps   [-f]
  35.  
  36. Priorities run in the range -128 to 127.
  37.  
  38. The CLI-process-number is that reported by the status and ps commands, and
  39. has values between 1 and 20.
  40.  
  41. Note that only AmigaDOS user processes can have their priority changed --
  42. you can't fiddle around with the priority of filesystem tasks, for
  43. instance. In general, this works for processes, not tasks.
  44.  
  45. using cpri
  46. ----------
  47. You have to take a certain amount of care in the use of this command. cpri'ing
  48. a cpu-bound process to a priority greater than zero will lock up your machine
  49. until it completes.
  50.  
  51. In order to experiment with this command, you can do the following:
  52.  
  53.         1. Create and compile cpuhog.c, which has the following contents:
  54.                 main()  { for(;;) Chk_Abort();  }
  55.         2. Run nine or ten cpuhogs in background. They'll be running at
  56.            priority -5.
  57.         3. See how the responsiveness of the initial CLI degrades as you
  58.            start cpri'ing each cpuhog command to priority 0.
  59.         4. To get rid of a cpuhog, use the break command:
  60.                 break CLI-process-number
  61.         5. If you *really* must, set the priority of a cpuhog to a +ve value.
  62.            Congratulations. You'll have to reboot, because your initial CLI
  63.            won't get any CPU until cpuhog completes or waits -- and it never
  64.            will!
  65.  
  66. suggested uses
  67. --------------
  68. You can prioritize background tasks. If two or more are running, temporarily
  69. lowering the priority of some will allow the others to complete faster.
  70.  
  71. ps
  72. --
  73. A replacement command for status, called "ps", is part of this package. I
  74. wrote it because I didn't like the way that status kept reporting most of
  75. my CLI commands as "????????". I assume that's a bug in status, but it may
  76. be a feature...
  77.  
  78. ps will report command names and process numbers. If given a "-f" command line
  79. flag, CLI type and process priority is also reported.
  80.  
  81. bugs
  82. ----
  83. cpri should really be folded into run. Sort of like the UNIX nice command.
  84.